package org.mspring.mlog.dao.impl;

import java.util.List;
import org.mspring.mlog.dao.AttachmentDao;
import org.mspring.mlog.entity.Attachment;
import org.mspring.platform.dao.hibernate.GenericDao;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Gao Youbo
 * @since 2014-01-11
 */
@Repository
public class AttachmentDaoImpl extends GenericDao<Attachment, Long> implements AttachmentDao {

    @Override
    public List<Attachment> listByForeign(long foreignKey, String foreignType) {
        return list("select a from Attachment a where a.from = ? and a.fid = ?", foreignType, foreignKey);
    }

    @Override
    public void deleteByForeign(long foreignKey, String foreignType) {
        executeUpdate("delete from Attachment a where a.from = ? and a.fid = ?", foreignType, foreignKey);
    }

}
